(function(win){
	win.Him=function(url,callback) {
		let _him=this;
		this.socket=io.connect(url,{transports:['websocket','xhr-polling','jsonp-polling']});
		this.on=function(eventName,callback){
			this.socket.on(eventName,callback);
		}
		this.onFriend=function(callback){
			this.on('MESSAGE_FRIEND',callback);
		}
		this.onGroup=function(callback){
			this.on('MESSAGE_GROUP',callback);
		}
		this.onSystem=function(callback){
			this.on('MESSAGE_SYSTEM',callback);
		}
		this.sendFriend=function(data){
			this.send('MESSAGE_FRIEND',data);
		}
		this.sendGroup=function(data){
			this.send('MESSAGE_GROUP',data);
		}
		this.sendSystem=function(data){
			this.send('MESSAGE_SYSTEM',data);
		}
		this.send=function(eventName,data){
			this.socket.emit(eventName,data);
		}
	}
})(window)
